<template>
  <div :style="{ height: tableY + 75 + 'px' }" style="margin-bottom: 40px;">
    <div class="margin-bottom-xs">
      <a-button
        type="danger"
        icon="delete"
        @click="handleSub($refs.table.selectedRowKeys)"
      >
        {{ $ct("delete", "删除") }}
      </a-button>
      <a-button
        class="cu-btn-danger"
        type="link"
        @click="() => $emit('clearAll')"
        >一键清空</a-button
      >
    </div>
    <!--	table	 -->
    <DataGrid
      ref="table"
      :columns="columns"
      :url="url"
      :queryParam="queryParam"
      rowKey="uuid"
      :format-conditions="true"
      :pageSize="20"
      :scroll="{
        y: tableY,
      }"
    >
      <span slot="renderUserNameId" slot-scope="{ text, record, index }">
        {{ record.userName }}/{{ record.userNameId }}
      </span>
      <template slot="renderOperationResponeArgs" slot-scope="{ text, record }">
        <a
          class="table-link"
          style="cursor: pointer"
          @click="() => $emit('handleEdit', record, 'operationLog')"
          >{{ record.operationContent }}</a
        >
      </template>
    </DataGrid>
  </div>
</template>

<script>
//数据表格组件
import { DataGrid } from "@/components";
//方法封装
import { dataGridMixin } from "@/mixins/dataGridMixin";

export default {
  name: "Table",
  components: { DataGrid },
  mixins: [dataGridMixin],
  filters: {},
  props: {
    tableY: 0,
    queryParam: {
      type: Object,
      defaultValue: () => {
        return {
          operationType: "requestLog.01",
        };
      },
    }, // 查询参数
  },
  data() {
    return {
      columns: [
        {
          title: "请求时间",
          dataIndex: "createTime",
          langCode: "requestTime",
          width: 200,
        },
        {
          title: "项目名称",
          dataIndex: "tenantName",
          langCode: "tenantName",
          width: 200,
        },
        {
          title: "请求账号",
          width: 160,
          dataIndex: "userNameId",
          langCode: "requestAccount",
          scopedSlots: {
            customRender: "renderUserNameId",
          },
        },
        {
          title: "请求IP",
          width: 160,
          dataIndex: "operationIp",
          langCode: "requestIP",
        },
        {
          title: "请求模块",
          width: 200,
          dataIndex: "operationModular",
        },
        {
          title: "请求描述",
          width: 200,
          dataIndex: "operationDesc",
          langCode: "requestDesc",
        },
        {
          title: "请求耗时",
          width: 80,
          dataIndex: "operationTime",
          langCode: "requestTimeConsuming",
        },
        {
          title: "操作记录",
          dataIndex: "operationContent",
          scopedSlots: {
            customRender: "renderOperationResponeArgs",
          },
        },
      ],
      visible: false,
      confirmLoading: false,
      mdl: null,
      url: {
        getPageSet: "/system/sysOperationLog/getPageSet",
        save: "/system/sysOperationLog/save",
        update: "/system/sysOperationLog/update",
        deleteBatch: "/system/sysOperationLog/deleteBatch",
      },
      startTime: "",
    };
  },
  methods: {},
};
</script>

<!--style-->
<style scoped lang="less">
.table {
  background-color: @base-bg-color;
  padding: 24px;
}
.table-link:hover {
  text-decoration: underline;
}
</style>
